import sys
import fileinput

import argparse


parser = argparse.ArgumentParser()
parser.add_argument("textToReplace", help="text To Replace")
args = parser.parse_args()

textToReplace=args.textToReplace


out=textToReplace+"_server.py"
textToSearch="nnnnnnnnn"


with open(out, 'w') as f:
    print(
        '''


from concurrent import futures
import time

import grpc

import nnnnnnnnn_pb2
import nnnnnnnnn_pb2_grpc

_ONE_DAY_IN_SECONDS = 60 * 60 * 24


class nnnnnnnnn(nnnnnnnnn_pb2_grpc.grpc_service_nnnnnnnnnServicer):
  def __init__(self):
        self.nnnnnnnnn_map = dict()

  def setnnnnnnnnn(self, request, context):
    print("receive set:")
    print("key:",request.nnnnnnnnn_request.nnnnnnnnn_key)
    print("value:",request.nnnnnnnnn_request.nnnnnnnnn_value)
    self.nnnnnnnnn_map[request.nnnnnnnnn_request.nnnnnnnnn_key]=request.nnnnnnnnn_request.nnnnnnnnn_value
    return nnnnnnnnn_pb2.nnnnnnnnnSetReply(nnnnnnnnn_key=request.nnnnnnnnn_request.nnnnnnnnn_key, flag=True)
  def getnnnnnnnnn(self, request, context):
    print("receive get:")
    print("key:",request.nnnnnnnnn_key)
    key=request.nnnnnnnnn_key
    ret=nnnnnnnnn_pb2.nnnnnnnnnGetReply(nnnnnnnnn_reply=nnnnnnnnn_pb2.nnnnnnnnn(nnnnnnnnn_key=key),flag=False)
    if key in self.nnnnnnnnn_map.keys():
          ret.flag=True
          ret.nnnnnnnnn_reply.nnnnnnnnn_value=self.nnnnnnnnn_map[key]
    return ret

def serve():
  server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
  nnnnnnnnn_pb2_grpc.add_grpc_service_nnnnnnnnnServicer_to_server(nnnnnnnnn(), server)
  server.add_insecure_port('[::]:50051')
  server.start()
  try:
    while True:
      time.sleep(_ONE_DAY_IN_SECONDS)
  except KeyboardInterrupt:
    server.stop(0)


if __name__ == '__main__':
  serve()


''', file=f)
with fileinput.FileInput(out, inplace=True) as file:
    for line in file:
        print(line.replace(textToSearch, textToReplace), end='')